<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type=text/javascript>
	jQuery(document).ready(function(){

		/*Check if the AskMyFriends extension exists!*/
		var check_port = chrome.extension.connect("hkfofinljmeoainkinmoionchfofdlob");
		check_port.onDisconnect.addListener(function(msg) {
			//DO NOTHING
			return ;
		});


		/*Listener for a new url*/
		chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
			if (changeInfo.status == "complete" ) {
				/*Check if there is a Friend who knows about the subject on the link!*/
				var url = "http://cyberang3l.ath.cx:33335/TempYesNo.php?link="+tab.url;
				// GET THE RESPONE FROM SERVER
				$.getJSON(url + "&jsoncallback=?", function(data){
					Answer = data.Answer;
					if (Answer == "YES") {
						//SEND A MESSAGE TO THE OTHER EXTENSION WITH THE LINK 
						// The ID of the extension we want to talk to.
						var laserExtensionId = "hkfofinljmeoainkinmoionchfofdlob";
						var port = chrome.extension.connect(laserExtensionId);
						port.postMessage({link: tabId});
					}
					
				})
			}
		});
	});
</script>